package com.kunyi.web.service.log.application.controller;

import com.github.pagehelper.PageInfo;
import com.kunyi.platform.tool.api.JsonResult;
import com.kunyi.web.service.log.entity.domain.LogSys;
import com.kunyi.web.service.log.entity.req.LogOpsListReq;
import com.kunyi.web.service.log.entity.req.LogSafeListReq;
import com.kunyi.web.service.log.entity.req.LogSysListReq;
import com.kunyi.web.service.log.entity.resp.*;
import com.kunyi.web.service.log.service.ILogOpsService;
import com.kunyi.web.service.log.service.ILogSafeService;
import com.kunyi.web.service.log.service.ILogSysService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName LogController
 * @Description 系统日志接口
 * @Author pengjunjun
 * @Date 2024/3/6 14:27
 * @Version 1.0
 **/
@Slf4j
@Api(tags = "系统日志-接口")
@RestController
@RequestMapping("/log")
public class LogController {
    @Autowired
    private ILogOpsService logOpsService;
    @Autowired
    private ILogSysService logSysService;
    @Autowired
    private ILogSafeService logSafeService;

    @ApiOperation("操作日志列表")
    @PostMapping("/ops/listPage")
    public JsonResult<PageInfo<LogOpsListResp>> opsListPage(@RequestBody LogOpsListReq req) {
        return JsonResult.success(logOpsService.pageByParam(req));
    }

    @ApiOperation("操作日志详情")
    @PostMapping("/ops/detail/{id}")
    public JsonResult<LogOpsDetailResp> opsDetail(@PathVariable Long id) {
        return JsonResult.success(logOpsService.detailById(id));
    }

    @ApiOperation("保存系统日志")
    @PostMapping("saveSys")
    public JsonResult<Long> save(@RequestBody LogSys logSys) {
        logSysService.save(logSys);
        return JsonResult.success(logSys.getId());
    }

    @ApiOperation("系统日志列表")
    @PostMapping("/sys/listPage")
    public JsonResult<PageInfo<LogSysListResp>> sysListPage(@RequestBody LogSysListReq req) {
        return JsonResult.success(logSysService.pageByParam(req));
    }

    @ApiOperation("系统日志详情")
    @PostMapping("/sys/detail/{id}")
    public JsonResult<LogSysDetailResp> sysDetail(@PathVariable Long id) {
        return JsonResult.success(logSysService.detailById(id));
    }

    @ApiOperation("安全日志列表")
    @PostMapping("/safe/listPage")
    public JsonResult<PageInfo<LogSafeListResp>> safeListPage(@RequestBody LogSafeListReq req) {
        return JsonResult.success(logSafeService.pageByParam(req));
    }

    @ApiOperation("安全日志详情")
    @PostMapping("/safe/detail/{id}")
    public JsonResult<LogSafeDetailResp> safeDetail(@PathVariable Long id) {
        return JsonResult.success(logSafeService.detailById(id));
    }


}
